package cn.bocai.pc.FileMonitorMethod;

import java.io.File;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/testMon")
public class Test {
	/* public static void main(String args[]){  
	        FileObserver ob = new FileObserver("D:/ruanjian/eclipse/file/newBcai/pc-image/src/main/webapp/2015");  
	        FileListener listener = new FileListener();  
	        ob.addListener(listener);  
	        FileMonitor monitor = new FileMonitor(ob);  
	        monitor.start();//开启线程
	      // monitor.stop();//关闭线程
	    } */ 
	
	public static void main(String args[]){  
		 File file = new File("D:/ruanjian/eclipse/file/newBcai/pc-image/src/main/webapp/2015/black/4");
	        File [] files = file.listFiles();
	        for (int i = 0; i < files.length; i++){
	            File file1 = files[i];
	            String name = file1.getName();   //根据后缀判断
	            System.out.println(name);
	        }
	    } 
	
	/* 
	 //保证线程的一致，这样才能准确关闭改线程
	 FileObserver ob = new FileObserver("D:/ruanjian/eclipse/file/newBcai/pc-image/src/main/webapp/2015");
	 FileMonitor monitor =null;
	//文件监听开始启动
	 @RequestMapping("/testStrt.do")
	 public void testStrt() {
		 FileListener listener = new FileListener();  
	     ob.addListener(listener);  
	     monitor = new FileMonitor(ob);
	     monitor.start();
	     System.out.println("文件夹监测启动");
	 }
	 
	//文件监听结束
	 @RequestMapping("/testStop.do")
	 public void testStop() {
		 monitor.stop();
		 System.out.println("文件夹监测结束");
	 }
	 */
	 
	
}
